/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.securityrat.entities_temp;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author p.vivoli
 */
@Entity
@Table(name = "perimetro")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Perimetro.findAll", query = "SELECT p FROM Perimetro p"),
    @NamedQuery(name = "Perimetro.findById", query = "SELECT p FROM Perimetro p WHERE p.id = :id"),
    @NamedQuery(name = "Perimetro.findByDescrizione", query = "SELECT p FROM Perimetro p WHERE p.descrizione = :descrizione")})
public class Perimetro implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "perimetro")
    private Collection<RelSp> relSpCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "id")
    private String id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "descrizione")
    private String descrizione;
    @Lob
    @Size(max = 65535)
    @Column(name = "note")
    private String note;
    @OneToMany(mappedBy = "idPerimetro")
    private Collection<Datatype> datatypeCollection;

    public Perimetro() {
    }

    public Perimetro(String id) {
        this.id = id;
    }

    public Perimetro(String id, String descrizione) {
        this.id = id;
        this.descrizione = descrizione;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescrizione() {
        return descrizione;
    }

    public void setDescrizione(String descrizione) {
        this.descrizione = descrizione;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @XmlTransient
    public Collection<Datatype> getDatatypeCollection() {
        return datatypeCollection;
    }

    public void setDatatypeCollection(Collection<Datatype> datatypeCollection) {
        this.datatypeCollection = datatypeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Perimetro)) {
            return false;
        }
        Perimetro other = (Perimetro) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.securityrat.entities.Perimetro[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<RelSp> getRelSpCollection() {
        return relSpCollection;
    }

    public void setRelSpCollection(Collection<RelSp> relSpCollection) {
        this.relSpCollection = relSpCollection;
    }
    
}
